package com.gxa.saas.portal.controller;

import com.gxa.saas.portal.service.GoodsDetailsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

@Api(value = "c端商品详情模块")
@Controller
public class GoodsDetailsController {

    @Autowired
    private GoodsDetailsService goodsDetailsService;

    @ApiOperation("商品详情")
    @ResponseBody
    @GetMapping("/GoodsDetails/details")
    public Map goodsDetails(@RequestParam("prId") String prId){
        Map map = new HashMap();
        if (StringUtils.isEmpty(prId)){
            map.put("code",400);
            map.put("message","prId参数错误");
            return map;
        }
        map =  this.goodsDetailsService.selectGoodsDetail(prId);
        if (MapUtils.isEmpty(map)){
            map.put("code","300");
            map.put("message","无数据");
            return map;
        }
        return map;
    }


}
